<?php if (!defined('THINK_PATH')) exit();?><!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<meta name="renderer" content="webkit|ie-comp|ie-stand">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
<meta http-equiv="Cache-Control" content="no-siteapp" />
<!--[if lt IE 9]>
<script type="text/javascript" src="/Public/Admin/lib/html5.js"></script>
<script type="text/javascript" src="/Public/Admin/lib/respond.min.js"></script>
<script type="text/javascript" src="/Public/Admin/lib/PIE_IE678.js"></script>
<![endif]-->
<link rel="icon" href="/bitbug_favicon.ico" />
<link href="/Public/Admin/css/H-ui.min.css" rel="stylesheet" type="text/css" />
<link href="/Public/Admin/css/H-ui.admin.css" rel="stylesheet" type="text/css" />
<link href="/Public/Admin/lib/icheck/icheck.css" rel="stylesheet" type="text/css" />
<link href="/Public/Admin/lib/Hui-iconfont/1.0.6/iconfont.css" rel="stylesheet" type="text/css" />
<link href="/Public/Admin/css/style.css" rel="stylesheet" type="text/css" />
<link rel="stylesheet" href="/Public/Admin/lib/zTree/v3/css/zTreeStyle/zTreeStyle.css" type="text/css">

<!--[if IE 6]>
<script type="text/javascript" src="http://lib.h-ui.net/DD_belatedPNG_0.0.8a-min.js" ></script>
<script>DD_belatedPNG.fix('*');</script>
<![endif]-->


<style>
	.search>ul{margin:0 auto;width:320px;}
	.search>ul>li{border:1px solid #ccc;border-radius:2px;}
	.search>ul>li>a{display:block;height:24px;line-height:24px;margin-left:7px;}
	.search>ul>li>a:hover{text-decoration: none;}
</style>
</head>
<body class="pos-r" style="position: relative;">
	<?php if($cat_id > 0): ?><div>
		<div class="text-c"> 日期范围：
			<input type="text" onfocus="WdatePicker()" id="logmin" class="input-text Wdate" style="width:120px;">
			-
			<input type="text" onfocus="WdatePicker()" id="logmax" class="input-text Wdate" style="width:120px;">
			<input type="text" name="" id="" placeholder=" 产品名称" style="width:250px" class="input-text">
			<button name="" id="" class="btn btn-success" type="submit"><i class="Hui-iconfont">&#xe665;</i> 搜产品</button>
		</div>
		<div class="cl pd-5 bg-1 bk-gray mt-20"> <span class="l"><a href="javascript:;" onclick="datadel()" class="btn btn-danger radius"><i class="Hui-iconfont">&#xe6e2;</i> 批量删除</a> <a class="btn btn-primary radius" onclick="product_add('添加商品','<?php echo U('goodsAdd',array('cat_id'=>$_GET['cat_id']));?>')" href="javascript:;"><i class="Hui-iconfont">&#xe600;</i> 添加商品</a></span> <span class="r">共有数据：<strong>54</strong> 条</span> </div>
		<div class="mt-20">
			<table class="table table-border table-bordered table-bg table-hover table-sort">
				<thead>
					<tr class="text-c">
						<th width="40"><input name="" type="checkbox" value=""></th>
						<th width="40">ID</th>
						<th width="100">产品名称</th>
						<th width="100">分类名称</th>
						<th>描述</th>
						<th width="100">市场价格</th>
						<th width="100">本店价格</th>
						<th width="60">是否上架</th>
						<th width="100">操作</th>
					</tr>
				</thead>
				<tbody>
					<?php if(is_array($goods)): $i = 0; $__LIST__ = $goods;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$v): $mod = ($i % 2 );++$i;?><tr class="text-c va-m">
						<td><input name="" type="checkbox" value=""></td>
						<td><?php echo ($v['id']); ?></td>
						<td class="text-c"><?php echo ($v['goods_name']); ?></td>
						<td class="text-c"><?php if(is_array($cats)): $i = 0; $__LIST__ = $cats;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$c): $mod = ($i % 2 );++$i; if($c['id'] == $v['cat_id']): echo ($c['cat_name']); endif; endforeach; endif; else: echo "" ;endif; ?></td>
						<td class="text-l"><?php echo (htmlspecialchars_decode($v['goods_desc'])); ?></td>
						<td><?php echo ($v['market_price']); ?></td>
						<td><?php echo ($v['shop_price']); ?></td>
						<td class="td-status"><a onclick="changeSale(this,<?php echo ($v['id']); ?>)"><img src="/Public/Admin/images/icon_<?php if($v["is_on_sale"]==1): ?>right<?php else: ?>error<?php endif; ?>_s.png"/></a></td>
						<td class="td-manage">
						<a style="text-decoration:none" href="<?php echo U('GoodsPhoto/photoList',array('goods_id'=>$v['id']));?>" title="商品tupian"><i class="Hui-iconfont">&#xe613;</i></a> 
						<a style="text-decoration:none" class="ml-5" onClick="product_edit('商品编辑','<?php echo U('goodsAdd',array('goods_id'=>$v['id'],'cat_id'=>$_GET['cat_id']));?>','10001')" href="javascript:;" title="编辑"><i class="Hui-iconfont">&#xe6df;</i></a> 
						<a style="text-decoration:none" class="ml-5" onClick="product_del(this,'<?php echo U('goods_del',array('goods_id'=>$v['id']));?>')" href="javascript:;" title="删除"><i class="Hui-iconfont">&#xe6e2;</i></a>
						</td>
					</tr><?php endforeach; endif; else: echo "" ;endif; ?>
				</tbody>
			</table>
		</div>
	</div>
	<?php else: ?>
	<div class="search" style="width:400px;height:160px;border: 1px solid #ccc;position: absolute;top: 50%;left: 50%;margin-top: -80px;margin-left: -200px;">
		<input id="search_cat" class="input-text radius" style="display:block;width: 320px;margin: 60px auto 0;" type="text" placeholder="请填写要搜索的栏目名称"/>
		<ul></ul>
	</div><?php endif; ?>

<script type="text/javascript" src="/Public/Admin/lib/jquery/1.9.1/jquery.min.js"></script> 
<script type="text/javascript" src="/Public/Admin/lib/icheck/jquery.icheck.min.js"></script> 
<script type="text/javascript" src="/Public/Admin/lib/Validform/5.3.2/Validform.min.js"></script>
<script type="text/javascript" src="/Public/Admin/lib/layer/2.1/layer.js"></script>
<script type="text/javascript" src="/Public/Admin/js/H-ui.js"></script> 
<script type="text/javascript" src="/Public/Admin/js/H-ui.admin.js"></script>
<script type="text/javascript" src="/Public/Admin/js/jquery.form.js"></script>
<script type="text/javascript" src="/Public/Admin/lib/My97DatePicker/WdatePicker.js"></script> 
<script type="text/javascript" src="/Public/Admin/lib/datatables/1.10.0/jquery.dataTables.min.js"></script> 
<script type="text/javascript" src="/Public/Admin/lib/zTree/v3/js/jquery.ztree.all-3.5.min.js"></script> 
<script type="text/javascript">

// 修改产品是否上架
function changeSale(obj,goods_id){
	$.post('<?php echo U("changeSale");?>',{goods_id:goods_id},function(res){
		if(res == 'error'){
			layer.msg('修改失败，请稍后重试！',{icon:5,time:1000});return;
		}
		
		if(res == 1){ // 上架
			$(obj).find('img').prop('src','/Public/Admin/images/icon_right_s.png');
		}else{ // 下架
			$(obj).find('img').prop('src','/Public/Admin/images/icon_error_s.png');
		}
	});
}

$(function(){
	$('#search_cat').keyup(function(){
		var obj = this;
		var cat_name = $(this).val();
		$.post('<?php echo U('searchCat');?>',{cat_name:cat_name},function(html){
			$(obj).next().html(html);
		})
	});
})
var code;
		
function showCode(str) {
	if (!code) code = $("#code");
	code.empty();
	code.append("<li>"+str+"</li>");
}
		
$(document).ready(function(){
	var t = $("#treeDemo");
	//t = $.fn.zTree.init(t, setting, zNodes);
	demoIframe = $("#testIframe");
	//demoIframe.bind("load", loadReady);
	var zTree = $.fn.zTree.getZTreeObj("tree");
	//zTree.selectNode(zTree.getNodeByParam("id",'11'));
});

/*图片-添加*/
function product_add(title,url){
	var index = layer.open({
		type: 2,
		title: title,
		content: url
	});
	layer.full(index);
}
/*图片-查看*/
function product_show(title,url,id){
	var index = layer.open({
		type: 2,
		title: title,
		content: url
	});
	layer.full(index);
}
/*图片-编辑*/
function product_edit(title,url,id){
	var index = layer.open({
		type: 2,
		title: title,
		content: url
	});
	layer.full(index);
}
/*图片-删除*/
function product_del(obj,url){
	layer.confirm('确认要删除吗？',function(index){
		$.get(url,function(res){
			if(res == 1){
				$(obj).parents("tr").remove();
				layer.msg('已删除!',{icon:1,time:1000});
			}else{
				layer.msg('删除失败，请重试!',{icon:5,time:1000});
			}
		})
		
	});
}
</script>
</body>


</html>